<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>融资机构基础信息 新增</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
            <form id="archivesInfo_form">
                <div class="fieldset1 tabel_col tabel_col_s clearFix ">
                    <div class="fieldBox col_100">
	                    <div class="label">权证名称</div>
	                    <div class="field">
	                        <input name="id" id="id" type="hidden" class="ui-textbox" value="${id}"  > 
	                        <input name="warrNm" id="warrNm" type="text" class="ui-textbox" value="${warrNm}" validate="{required:true, maxlength:100}">
	                    </div>
	                </div>
                    <div class="fieldBox col_100">
	                    <div class="label">权证类别</div>
	                    <div class="field">
							<select name="warrTypeCd" id="warrTypeCd" >
								<option value=" " selected = "selected">请选择</option>
								<option value="1" <c:if test="${warrTypeCd == '1'}">selected = "selected"</c:if> >合同资料</option>
								<option value="2" <c:if test="${warrTypeCd == '2'}">selected = "selected"</c:if> >承租人资料</option>
								<option value="3" <c:if test="${warrTypeCd == '3'}">selected = "selected"</c:if> >权证资料</option>
								<option value="4" <c:if test="${warrTypeCd == '4'}">selected = "selected"</c:if> >其他资料</option>
								<option value="5" <c:if test="${warrTypeCd == '5'}">selected = "selected"</c:if> >担保人资料</option>
							</select>
						</div>
	                </div>
                    <div class="fieldBox col_100">
	                    <div class="label">权证级别</div>
	                    <div class="field">
							<select name="warrLv" id="warrLv" >
								<option value=" " selected = "selected">请选择</option>
								<option value="1" <c:if test="${warrLv == '1'}">selected = "selected"</c:if> >A（公开）</option>
								<option value="2" <c:if test="${warrLv == '2'}">selected = "selected"</c:if> >B（保密）</option>
							</select>
						</div>
	                </div>
                    <div class="fieldBox col_100">
	                    <div class="label">客户类型</div>
	                    <div class="field">
							<select name="custTypeCd" id="custTypeCd" >
								<option value=" " selected = "selected">请选择</option>
								<option value="1" <c:if test="${custTypeCd == '1'}">selected = "selected"</c:if> >自然人</option>
								<option value="2" <c:if test="${custTypeCd == '2'}">selected = "selected"</c:if> >法人</option>
							</select>
						</div>
	                </div>
                    <div class="fieldBox col_100">
	                    <div class="label">婚姻状况</div>
	                    <div class="field">
							<select name="warStsCd" id="warStsCd" >
								<option value=" " selected = "selected">请选择</option>
								<option value="1" <c:if test="${warStsCd == '1'}">selected = "selected"</c:if> >已婚</option>
								<option value="2" <c:if test="${warStsCd == '2'}">selected = "selected"</c:if> >未婚</option>
							</select>
						</div>
	                </div>
                </div>
            </form>
</div>


<script type="text/javascript">
$(function(){
	//加载数据
    /* if($("#id").val() != ''){
    	initData();
    } */
	$('#archivesInfo_form').ligerForm({
	        validate : true
	});
    SET_popupIframeHeight();
});

//定义父级调用事件
frameElement.dialog.onOk = function () {
	check();
}
           
frameElement.dialog.onCancel = function () {
     frameElement.dialog.close();
}

function check(){
	//var form = liger.get("archivesInfo_form");
	if (!$("#archivesInfo_form").valid()) {
    	top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
    	return false; //验证不通过，不执行以下代码
    }
	if($("#warrTypeCd").val() == ""){
		top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
    	return false; //验证不通过，不执行以下代码
	}
	if($("#warrLv").val() == ""){
		top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
    	return false; //验证不通过，不执行以下代码
	}
	if($("#custTypeCd").val() == ""){
		top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
    	return false; //验证不通过，不执行以下代码
	}
	if($("#warStsCd").val() == ""){
		top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
    	return false; //验证不通过，不执行以下代码
	}
	var ligerForm = new liger.get("#archivesInfo_form");
	var _data = $("form").serializeArray();
	//var data = ligerForm.getData();
	var _url = '<%=path%>/basic/archivesinfo/add.do';
	if(StringUtils.isNotEmpty($("#id").val())){
		_url = '<%=path%>/basic/archivesinfo/modify.do';
	}
	//发送异步请求校验
	var wait_dialog;
	$.ajax({
		type: 'post',
		dataType: 'json',
		data: _data,
		url: _url,
		beforeSend: function(){
	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		},
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				parent.grid.reload();
				frameElement.dialog.close();
			 }else if(msg.success == 0 && !msg.data){//校验不成功,且没有data(id)报错
				top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				frameElement.dialog.close();
			 }
		}
	});
}

function initData(){
	var _id = $("#id").val();
	if (StringUtils.isEmpty(id))
		return;
	var _url = '<%=path%>/basic/archivesinfo/getById.do';
	AjaxUtils.ajaxGet(_url, {
		id : _id
	}, initCallback);
}

//初始化回调
function initCallback(msg) {
	if (msg.success == 1) {
		setData(msg.data);//设置数据
	} else {
		top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	}
}

//修改时候设置页面数据
function setData(data) {
	$("#warrNm").val(data.warrNm);
	$("#warrTypeCd").val("4");
	$("#warrLv").val(data.warrLv);
	$("#custTypeCd").val(data.custTypeCd);
	$("#warStsCd").val(data.warStsCd);
}

</script>



</body>
</html>
